From 7343afbfa78b569ca11b75821966df8047c69b05 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 23 Jul 2014 09:36:49 -0700 Subject: [PATCH] Only copy over the native output directory once Previously it was copying once per target, not once per package. --- src/cargo/ops/cargo_rustc/fingerprint.rs | 11 +++++-- tests/test_cargo_test.rs | 40 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index c72fa7c73..df17c0d7f 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -47,11 +47,16 @@ pub fn prepare(cx: &mut Context, pkg: &Package, // Prepare a job to copy over all old artifacts into their new destination. let mut pairs = Vec::new(); pairs.push((old_fingerprint_loc, new_fingerprint_loc)); + + // TODO: this shouldn't explicitly pass false, for more info see + // cargo_rustc::compile_custom + if pkg.get_manifest().get_build().len() > 0 { + let layout = cx.layout(false); + pairs.push((layout.old_native(pkg), layout.native(pkg))); + } + for &target in targets.iter() { let layout = cx.layout(target.get_profile().is_plugin()); - if pkg.get_manifest().get_build().len() > 0 { - pairs.push((layout.old_native(pkg), layout.native(pkg))); - } for filename in cx.target_filenames(target).iter() { let filename = filename.as_slice(); pairs.push((layout.old_root().join(filename), diff --git a/tests/test_cargo_test.rs b/tests/test_cargo_test.rs index 16eb46dda..09936b00b 100644 --- a/tests/test_cargo_test.rs +++ b/tests/test_cargo_test.rs @@ -559,3 +559,43 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured\n\n\ fresh = FRESH, dir = p.root().display()).as_slice())); }) + +test!(test_twice_with_build_cmd { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + build = 'true' + "#) + .file("src/lib.rs", " + #[test] + fn foo() {} + "); + + assert_that(p.cargo_process("cargo-test"), + execs().with_status(0) + .with_stdout(format!("\ +{compiling} foo v0.0.1 (file:{dir}) + +running 1 test +test foo ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured\n\n\ + ", + compiling = COMPILING, + dir = p.root().display()).as_slice())); + assert_that(p.process(cargo_dir().join("cargo-test")), + execs().with_status(0) + .with_stdout(format!("\ +{fresh} foo v0.0.1 (file:{dir}) + +running 1 test +test foo ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured\n\n\ + ", + fresh = FRESH, + dir = p.root().display()).as_slice())); +}) -- 2.30.2